home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / super_su.swf / scripts / DefineSprite_640 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-04-19  |  12.7 KB  |  384 lines

  1. function mSelectFoe(strID)
  2. {
  3.    this.oFoe = this["oFoe_" + strID];
  4.    var i = 1;
  5.    while(i < 5)
  6.    {
  7.       var name = "Mojo" + i;
  8.       if(name != strID)
  9.       {
  10.          this["oFoe_" + name].unloadMovie();
  11.       }
  12.       i++;
  13.    }
  14. }
  15. function mInitObjects()
  16. {
  17.    this.mKillObstacules();
  18.    this.oChar.oWave = this.oWave;
  19.    this.oChar.intPosX = 0;
  20.    this.oChar.intPosY = -10;
  21.    this.oChar.intVelX = 10;
  22.    this.oChar.intVelY = 0;
  23.    this.oChar.intGravity = -1.5;
  24.    this.oChar.strmedia = "wave";
  25.    this.oChar.intAngle = -0.7853981633974483;
  26.    this.oChar.strMode = "surfing";
  27.    this.mSetPose("surfing");
  28.    this.oWave.oChar = this.oChar;
  29.    this.oWave.oClosingWave = this.oClosingWave;
  30.    this.oWave.intPosX = -5000;
  31.    this.oWave.intPosY = 0;
  32.    this.oWave.intVelX = 15;
  33.    this.oWave.intVelY = 0;
  34.    this.oWave.intGround = -215;
  35.    this.oWave.intFinish = 10000;
  36.    this.oControls.oChar = this.oChar;
  37.    this.oControls.intStep = 0.09817477042468103;
  38.    this.oControls.mult = 2;
  39.    if(this._parent.intLevel == 1)
  40.    {
  41.       this.mSelectFoe("Mojo1");
  42.       this.oFoe.intGapX = 250;
  43.       this.oFoe.intPosX = 5500;
  44.       this.oFoe.intPosY = -45;
  45.       this.oFoe.intVelX = 0;
  46.       this.oFoe.defaultTime = 30;
  47.       this.oFoe.defaultBombSpeed = -25;
  48.       this.oWave.intPosX = -3000;
  49.       this.oWave.intVelX = 11;
  50.       this.mNewObstacule(500,-50,0,0,"obstaculo_04");
  51.       this.mNewObstacule(1000,25,0,0,"energia_01");
  52.       this.mNewObstacule(1000,-100,0,0,"energia_03");
  53.       this.mNewObstacule(1250,-150,0,0,"obstaculo_05");
  54.       this.mNewObstacule(1500,-100,0,0,"obstaculo_07");
  55.       this.mNewObstacule(1750,-50,0,0,"obstaculo_05");
  56.       this.mNewObstacule(2000,-175,0,0,"obstaculo_08");
  57.       this.mNewObstacule(2250,-100,0,0,"obstaculo_04");
  58.       this.mNewObstacule(2500,0,0,0,"energia_01");
  59.       this.mNewObstacule(2750,50,0,0,"energia_01");
  60.       this.mNewObstacule(3000,100,0,0,"energia_01");
  61.       this.mNewObstacule(3500,100,0,0,"energia_03");
  62.       this.mNewObstacule(3500,0,0,0,"obstaculo_08");
  63.       this.mNewObstacule(3500,-150,0,0,"obstaculo_06");
  64.       this.mNewObstacule(3750,-100,0,0,"obstaculo_02");
  65.       this.mNewObstacule(4000,-50,0,0,"obstaculo_03");
  66.       this.mNewObstacule(4500,25,0,0,"energia_01");
  67.       this.mNewObstacule(4750,75,0,0,"energia_01");
  68.       this.mNewObstacule(5000,125,0,0,"energia_01");
  69.       this.mNewObstacule(5000,0,0,0,"obstaculo_08");
  70.       this.mNewObstacule(8250,-100,0,0,"obstaculo_06");
  71.       this.mNewObstacule(8500,0,0,0,"obstaculo_08");
  72.    }
  73.    if(this._parent.intLevel == 2)
  74.    {
  75.       this.mSelectFoe("Mojo2");
  76.       this.oFoe.intGapX = 250;
  77.       this.oFoe.intPosX = 5000;
  78.       this.oFoe.intPosY = -45;
  79.       this.oFoe.intVelX = 0;
  80.       this.oFoe.defaultTime = 25;
  81.       this.oFoe.defaultBombSpeed = -25;
  82.       this.oWave.intPosX = -3000;
  83.       this.oWave.intVelX = 12;
  84.       this.mNewObstacule(500,-50,0,0,"obstaculo_04");
  85.       this.mNewObstacule(500,-150,0,0,"obstaculo_04");
  86.       this.mNewObstacule(1000,-100,0,0,"energia_03");
  87.       this.mNewObstacule(1000,25,0,0,"energia_01");
  88.       this.mNewObstacule(1000,75,0,0,"energia_01");
  89.       this.mNewObstacule(1250,-150,0,0,"obstaculo_07");
  90.       this.mNewObstacule(1750,-50,0,0,"obstaculo_07");
  91.       this.mNewObstacule(2000,-175,0,0,"obstaculo_08");
  92.       this.mNewObstacule(2250,-100,0,0,"obstaculo_04");
  93.       this.mNewObstacule(2500,0,0,0,"energia_01");
  94.       this.mNewObstacule(2750,50,0,0,"energia_01");
  95.       this.mNewObstacule(3000,25,-10,0,"mc_pelicano");
  96.       this.mNewObstacule(3250,150,0,0,"energia_01");
  97.       this.mNewObstacule(3500,100,0,0,"energia_03");
  98.       this.mNewObstacule(3500,-150,0,0,"obstaculo_06");
  99.       this.mNewObstacule(3750,-100,0,0,"obstaculo_02");
  100.       this.mNewObstacule(4000,25,-10,0,"mc_pelicano");
  101.       this.mNewObstacule(4000,-50,0,0,"obstaculo_03");
  102.       this.mNewObstacule(4500,25,0,0,"energia_01");
  103.       this.mNewObstacule(4750,75,0,0,"energia_01");
  104.       this.mNewObstacule(5000,125,0,0,"energia_01");
  105.       this.mNewObstacule(5000,0,0,0,"obstaculo_08");
  106.       this.mNewObstacule(5500,25,-10,0,"mc_pelicano");
  107.       this.mNewObstacule(6500,25,-10,0,"mc_pelicano");
  108.       this.mNewObstacule(9000,25,0,0,"mc_pelicano");
  109.       this.mNewObstacule(9500,25,0,0,"mc_pelicano");
  110.       this.mNewObstacule(9500,-100,0,0,"obstaculo_04");
  111.    }
  112.    if(this._parent.intLevel == 3)
  113.    {
  114.       this.mSelectFoe("Mojo3");
  115.       this.oFoe.intGapX = 250;
  116.       this.oFoe.intPosX = 5000;
  117.       this.oFoe.intPosY = -45;
  118.       this.oFoe.intVelX = 0;
  119.       this.oFoe.defaultTime = 20;
  120.       this.oFoe.defaultBombSpeed = -20;
  121.       this.oWave.intPosX = -2500;
  122.       this.oWave.intVelX = 12;
  123.       this.mNewObstacule(500,-50,0,0,"obstaculo_01");
  124.       this.mNewObstacule(500,-125,0,0,"obstaculo_02");
  125.       this.mNewObstacule(1000,50,0,0,"energia_06");
  126.       this.mNewObstacule(1250,-100,0,0,"obstaculo_06");
  127.       this.mNewObstacule(1500,-150,0,0,"obstaculo_08");
  128.       this.mNewObstacule(1750,-75,0,0,"obstaculo_07");
  129.       this.mNewObstacule(2000,-175,0,0,"obstaculo_08");
  130.       this.mNewObstacule(2500,-100,0,0,"mc_tiburon");
  131.       this.mNewObstacule(2500,0,0,0,"energia_01");
  132.       this.mNewObstacule(2750,50,0,0,"energia_01");
  133.       this.mNewObstacule(3000,100,0,0,"energia_01");
  134.       this.mNewObstacule(3250,125,0,0,"energia_06");
  135.       this.mNewObstacule(3500,100,0,0,"energia_06");
  136.       this.mNewObstacule(3500,0,0,0,"obstaculo_08");
  137.       this.mNewObstacule(3750,-50,0,0,"obstaculo_02");
  138.       this.mNewObstacule(4000,-100,0,0,"obstaculo_03");
  139.       this.mNewObstacule(4500,50,0,0,"energia_01");
  140.       this.mNewObstacule(4750,100,0,0,"energia_01");
  141.       this.mNewObstacule(5000,125,0,0,"energia_06");
  142.       this.mNewObstacule(5000,0,0,0,"obstaculo_08");
  143.       this.mNewObstacule(5000,-100,0,0,"mc_tiburon");
  144.       this.mNewObstacule(5250,100,0,0,"energia_06");
  145.       this.mNewObstacule(5300,100,0,0,"energia_06");
  146.       this.mNewObstacule(9000,-100,-10,0,"mc_tiburon");
  147.       this.mNewObstacule(4250,40,0,0,"obstaculo_10_vida");
  148.    }
  149.    if(this._parent.intLevel == 4)
  150.    {
  151.       this.mSelectFoe("Mojo4");
  152.       this.oFoe.intGapX = 250;
  153.       this.oFoe.intPosX = 5000;
  154.       this.oFoe.intPosY = -45;
  155.       this.oFoe.intVelX = 0;
  156.       this.oFoe.defaultTime = 20;
  157.       this.oFoe.defaultBombSpeed = -20;
  158.       this.oWave.intPosX = -2500;
  159.       this.oWave.intVelX = 13;
  160.       this.mNewObstacule(500,-150,0,0,"obstaculo_01");
  161.       this.mNewObstacule(750,-50,0,0,"obstaculo_04");
  162.       this.mNewObstacule(1000,50,0,0,"energia_01");
  163.       this.mNewObstacule(1000,100,0,0,"energia_01");
  164.       this.mNewObstacule(1000,125,0,0,"energia_06");
  165.       this.mNewObstacule(1025,125,0,0,"energia_06");
  166.       this.mNewObstacule(1250,-100,0,0,"obstaculo_05");
  167.       this.mNewObstacule(1750,-75,0,0,"obstaculo_07");
  168.       this.mNewObstacule(2000,0,0,0,"obstaculo_08");
  169.       this.mNewObstacule(2250,-100,0,0,"mc_tiburon");
  170.       this.mNewObstacule(2500,50,0,0,"energia_01");
  171.       this.mNewObstacule(2750,75,0,0,"energia_01");
  172.       this.mNewObstacule(3000,100,0,0,"energia_06");
  173.       this.mNewObstacule(3000,25,-10,0,"mc_pelicano");
  174.       this.mNewObstacule(3250,100,0,0,"energia_06");
  175.       this.mNewObstacule(3500,50,0,0,"energia_01");
  176.       this.mNewObstacule(3500,0,0,0,"obstaculo_08");
  177.       this.mNewObstacule(3500,-100,0,0,"obstaculo_06");
  178.       this.mNewObstacule(3750,-50,0,0,"obstaculo_03");
  179.       this.mNewObstacule(4000,25,-10,0,"mc_pelicano");
  180.       this.mNewObstacule(4000,-100,0,0,"obstaculo_02");
  181.       this.mNewObstacule(4500,50,0,0,"energia_01");
  182.       this.mNewObstacule(4750,100,0,0,"energia_01");
  183.       this.mNewObstacule(5000,125,0,0,"energia_06");
  184.       this.mNewObstacule(5000,0,0,0,"obstaculo_08");
  185.       this.mNewObstacule(5500,25,-10,0,"mc_pelicano");
  186.       this.mNewObstacule(5500,-100,0,0,"mc_tiburon");
  187.       this.mNewObstacule(6500,25,-10,0,"mc_pelicano");
  188.       this.mNewObstacule(8000,-100,0,0,"mc_tiburon");
  189.       this.mNewObstacule(9000,25,0,0,"mc_pelicano");
  190.       this.mNewObstacule(9500,25,0,0,"mc_pelicano");
  191.       this.mNewObstacule(9500,-100,0,0,"mc_tiburon");
  192.       this.mNewObstacule(4250,40,0,0,"obstaculo_10_vida");
  193.    }
  194.    this.arrObs.push(this.oFoe);
  195. }
  196. function mInitGame()
  197. {
  198.    this.mInitObjects();
  199. }
  200. function mDraw()
  201. {
  202.    var intCamX = 300;
  203.    var CamIntPosX = this.oChar.intPosX;
  204.    this.oChar._x = intCamX;
  205.    this.oChar._y = 165 - this.oChar.intPosY;
  206.    this.oChar.oImage.mSetAngle(this.oChar.intAngle);
  207.    this.oWave._y = this.oWave.intY;
  208.    this.oClosingWave._y = this.oWave.intY;
  209.    this.oClosingWave._x = intCamX + CamIntPosX - this.oWave.intPosX;
  210.    var i = 0;
  211.    while(i < this.arrObs.length)
  212.    {
  213.       var obs = this.arrObs[i];
  214.       obs._x = intCamX + CamIntPosX - obs.intPosX;
  215.       obs._y = 165 - obs.intPosY;
  216.       this.oProgressBar.mRefresh();
  217.       i++;
  218.    }
  219.    this.oChar._y += this.oChar.intPosY / 3;
  220.    this.oWave._y += this.oChar.intPosY / 3;
  221.    this.oClosingWave._y += this.oChar.intPosY / 3;
  222.    var i = 0;
  223.    while(i < this.arrObs.length)
  224.    {
  225.       var obs = this.arrObs[i];
  226.       obs._y += this.oChar.intPosY / 3;
  227.       i++;
  228.    }
  229. }
  230. function mNewObstacule(intX, intY, intVelX, intVelY, strType)
  231. {
  232.    this.intDepth = this.intDepth + 1;
  233.    var newdepth = this.intDepth;
  234.    var newname = "oObs" + newdepth;
  235.    this.attachMovie(strType,newname,newdepth);
  236.    this[newname].intPosX = intX;
  237.    this[newname].intPosY = intY;
  238.    this[newname].intVelX = intVelX;
  239.    this[newname].intVelY = intVelY;
  240.    this.arrObs.push(this[newname]);
  241. }
  242. function mNewScore(intscore, aintX, aintY, aintDepth)
  243. {
  244.    this.intDepth = this.intDepth + 1;
  245.    var newdepth = this.intDepth;
  246.    var newname = "puf_" + newdepth;
  247.    this.attachMovie("energia_puf",newname,newdepth);
  248.    this[newname].intPosX = aintX;
  249.    this[newname].intPosY = aintY;
  250.    this[newname].intVelY = 3;
  251.    this[newname].strScore = intscore;
  252.    this.arrObs.push(this[newname]);
  253.    this.mAddScore(intscore);
  254.    this.sndBonus.start();
  255. }
  256. function mStepFrame()
  257. {
  258.    var newDate = new Date();
  259.    if(this.oldDate == 0)
  260.    {
  261.       this.oldDate = newDate;
  262.    }
  263.    var dT = newDate - this.oldDate;
  264.    var interval = this.velocidad * dT / 1000;
  265.    this.oldDate = newDate;
  266.    this.strInterval = interval;
  267.    if(interval > 2)
  268.    {
  269.       interval = 2;
  270.    }
  271.    this.oControls.mStepFrame(interval);
  272.    this.oWave.mStepFrame(interval);
  273.    this.oChar.mStepFrame(interval);
  274.    var i = 0;
  275.    while(i < this.arrObs.length)
  276.    {
  277.       var obs = this.arrObs[i];
  278.       obs.mStepFrame(interval);
  279.       i++;
  280.    }
  281.    this.mDraw();
  282.    this.mDoScore();
  283. }
  284. function mKillObject(aObject)
  285. {
  286.    var i = 0;
  287.    while(i < this.arrObs.length)
  288.    {
  289.       if(this.arrObs[i] == aObject)
  290.       {
  291.          aObject.unloadMovie();
  292.          this.arrObs.splice(i,1);
  293.       }
  294.       i++;
  295.    }
  296. }
  297. function mKillObstacules()
  298. {
  299.    var i = 0;
  300.    while(i < this.arrObs.length)
  301.    {
  302.       this.arrObs.unloadMovie();
  303.       i++;
  304.    }
  305.    this.arrObs = new Array();
  306. }
  307. function mResetWave()
  308. {
  309.    this.oChar.mReset();
  310.    this.oFoe.mReset();
  311.    this.oWave.mReset();
  312. }
  313. function mDoScore()
  314. {
  315.    var checkPoint = Math.floor(this.oChar.intPosX / this.intCheckpointGap);
  316.    if(checkpoint > this.arrCheckPoint)
  317.    {
  318.       this.arrCheckPoint = checkpoint;
  319.       this.mAddScore(this.intPointsXGap);
  320.    }
  321. }
  322. function mAddScore(intscore)
  323. {
  324.    this._parent.mAddScore(intscore);
  325.    this.oScore.mSetScore(this._parent.intScore);
  326. }
  327. function mSetCharacter(astrchar)
  328. {
  329.    this._parent.mSetCharacter(astrchar);
  330. }
  331. function mResumeLevel()
  332. {
  333.    this._parent.mResumeLevel();
  334. }
  335. function mStartGame()
  336. {
  337.    this._parent.mStartGame();
  338. }
  339. function mLooseLife()
  340. {
  341.    this.sndFondo.stop();
  342.    this.strCommand = "looselife";
  343.    this.gotoAndPlay("nocontrol");
  344. }
  345. function mGameOver()
  346. {
  347.    this._parent.mGameOver();
  348. }
  349. function mJumpLevel()
  350. {
  351.    this.strCommand = "jumplevel";
  352.    this.gotoAndPlay("nocontrol");
  353. }
  354. function mRelease()
  355. {
  356.    this.sndFondo.stop();
  357.    if(this.strCommand == "looselife")
  358.    {
  359.       this._parent.mLooseLife();
  360.    }
  361.    if(this.strCommand == "jumplevel")
  362.    {
  363.       this._parent.mJumpLevel();
  364.    }
  365. }
  366. this.sndFondo = new Sound(this);
  367. this.sndFondo.attachSound("base_juego.wav");
  368. this.sndBonus = new Sound(this);
  369. this.sndBonus.attachSound("bonus.wav");
  370. this.sndFondo.start(0,9999);
  371. this.velocidad = 18;
  372. this.intCheckpointGap = 100;
  373. this.intPointsXGap = 5;
  374. this["oChar_" + this._parent.strChar].duplicateMovieClip("oChar",500);
  375. this.oChar_bl.unloadMovie();
  376. this.oChar_bb.unloadMovie();
  377. this.oChar_bc.unloadMovie();
  378. this.hexColorRopa = this._parent.hexColorRopa;
  379. this.hexColorTabla = this._parent.hexColorTabla;
  380. this.oClosingWave_dumb.duplicateMovieClip("oClosingWave",504);
  381. this.oClosingWave_dumb.unloadMovie();
  382. this.arrObs = new Array();
  383. this.intDepth = 50;
  384.